package com.jj.service.impl;

import com.jj.entity.Allocation;
import com.jj.entity.Dormitory;
import com.jj.entity.Student;
import com.jj.mapper.StudentMapper;
import com.jj.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(readOnly = true)
public class StudentServiceImpl implements StudentService {
    @Autowired
    private StudentMapper studentMapper;
    @Override
    public List<Student> selectAllStudent() {
        return studentMapper.selectAllStudent();
    }

    @Override
    public Student selectAllByIdStudent(Long id) {
        return studentMapper.selectAllByIdStudent(id);
    }

    @Override
    @Transactional
    public boolean addStudent(Student student) {
        return studentMapper.addStudent(student)>0 ? true : false;
    }

    @Override
    @Transactional
    public boolean updateStudent(Student student) {
        return studentMapper.updateStudent(student)>0 ? true : false;
    }

    @Override
    @Transactional
    public boolean deleteStudent(Long id) {
        return studentMapper.deleteStudent(id)>0 ? true : false;
    }
}
